<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>客户合同新建</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="../../lib/layui/layui/css/layui.css">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui/lay/dest/layui.all.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>
    <style>
        * {font-family: "Microsoft Yahei" !important;}
        b{
            color: red;
        }
        .head_title{
            margin-top: 10px;
            height: 40px;
            position: relative;
        }
        .head_title .title{
            margin-left: 22px;
        }
        .head_title span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .saveBtn{
            display: block;
            float: left;
            background: url(../img/confirm.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .resetBtn {
            display: block;
            float: left;
            background: url(../img/news/new_filling.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .div_Btn{
            margin: 1% 43%;
        }
        select{
            width: 250px;
            height: 30px;
        }
        .newTbale tr td {
            border-right: #ccc 1px solid;
            padding: 5px 30px;
        }
        input[type="text"]{
            width: 250px;
            height: 30px;
        }
        .newTbale {
            width: 85%;
            margin: 0px auto;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }
    </style>
   <%-- <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>--%>
</head>
<body>
<!--head开始-->
<div class="head_title">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span >客户合同新建</span>
    </div>
</div>
<div id="pagediv">
    <form id="ajaxforms" action="/addCrmContract/addCrmContract">
        <table class="newTbale">
            <tr>

                <td>合同名称:</td>
                <td><input type="text" name="contractName"/><b>*</b></td>
                <td>所属客户</td>
                <td>
                    <select name="customerId" style="width: 252px" >
                        <option >选择客户</option>
                    </select>
                    <b>*</b>
                </td>


            </tr>
            <tr>
                <td>合同类型:</td>
                <td>
                    <select name="type" style="width: 252px" >
                        <option value="">选择付款方式</option>
                    <%--    <option value="0">产品销售</option>
                        <option value="1">业务销售</option>
                        <option value="2">售后服务</option>--%>
                    </select>
                    <b>*</b>
                </td>

                <td>合同状态:</td>
                <td>
                    <select name="status" style="width: 252px" >
                        <option value="0">执行中</option>
                        <option value="1">结束</option>
                        <option value="2">意外终止</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>总金额:</td>
                <td><input type="text" name="total" maxlength="10"/></td>
                <td>总金额大写:</td>
                <td><input type="text" name="totalCaps" maxlength="10"/></td>
            </tr>
            <tr>
                <td>付款方式:</td>
                <td>
                    <select name="payWay">
                        <option value="">选择付款方式</option>
                    </select>
                    <b>*</b>
                </td>
                <td>已收款:</td>
                <td><input type="text" name="receivedMoney" maxlength="10"/></td>
            </tr>
            <tr>
                <td>开始时间:</td>
                <td>
                   <%-- <input type="text" name="startTime"   placeholder="请输入时间" id="startTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                    <input  name="startTime" id="startTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                </td>
                <td>结束时间:</td>
                <td>
                    <%--<input type="text" name="endTime"   placeholder="请输入时间" id="endTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                    <input  name="endTime" id="endTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                </td>
            </tr>
            <tr>
                <td>合同有效期:</td>
                <td>
                    <%--<input type="text" name="validTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                    <input  name="validTime" id="validTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                </td>
                <td>到期事务提醒:</td>
                <td disabled="true">
                    <input type="radio" name="remindExpire" checked="checked"   value="0"/>否
                    <input type="radio" name="remindExpire"   value="1"/>是
                </td>
            </tr>
            <tr>
                <td>到期短信提醒:</td>
                <td disabled="true">
                    <input type="radio" name="remindExpireSms" checked="checked"   value="0"/>否
                    <input type="radio" name="remindExpireSms"   value="1"/>是
                </td>
                <td>收款时间:</td>
                <td>
                  <%--  <input type="text" name="recieveTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                      <input  name="recieveTime" id="recieveTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                </td>
            </tr>
            <tr>
                <td>交付时间:</td>
                <td>
                    <%--<input type="text" name="deliverTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                    <input  name="deliverTime" id="deliverTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                </td>
                <td>收款事务提醒:</td>
                <td disabled="true">
                    <input type="radio" name="remindRecieve" checked="checked"   value="0"/>否
                    <input type="radio" name="remindRecieve"   value="1"/>是
                </td>
            </tr>
            <tr>
                <td>收款短信提醒:</td>
                <td disabled="true">
                    <input type="radio" name="remindRecieveSms" checked="checked"   value="0"/>否
                    <input type="radio" name="remindRecieveSms"   value="1"/>是
                </td>
                <td>交付事务提醒:</td>
                <td disabled="true">
                    <input type="radio" name="remindDeliver" checked="checked"   value="0"/>否
                    <input type="radio" name="remindDeliver"   value="1"/>是
                </td>
            </tr>
            <tr>
                <td>交付短信提醒:</td>
                <td disabled="true">
                    <input type="radio" name="remindDeliverSms" checked="checked"   value="0"/>否
                    <input type="radio" name="remindDeliverSms"   value="1"/>是
                </td>
                <td>合同内容:</td>
                <td><input type="text" name="content"/></td>
            </tr>
            <tr>
                <td>甲方签约时间:</td>
                <td>
                    <%--<input type="text" name="fistPartySignTime" readonly="readonly"  placeholder="请输入时间" id="fistPartySignTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                    <input  name="fistPartySignTime" id="fistPartySignTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                </td>
                <td>甲方:</td>
                <td><input type="text" name="fistParty"/></td>
            </tr>
            <tr>
                <td>乙方签约时间:</td>
                <td>
                    <%--<input type="text" name="secondPartySignTime" readonly="readonly"  placeholder="请输入时间" id="secondPartySignTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                        <input  name="secondPartySignTime" id="secondPartySignTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                    </td>
                <td>乙方:</td>
                <td><input type="text" name="secondParty"/></td>
            </tr>
            <tr>
                <td>项目:</td>
                <td><input type="text" name="item"/></td>
                <td>审批状态:</td>
                <td>
                    <select name="approvalStatus" style="width: 252px" >
                        <option value="0">待审批</option>
                        <option value="1">已通过</option>
                        <option value="2">已驳回</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>审批人:</td>
                <td><input type="text" name="approvalUser"/></td>
                <td>审批时间:</td>
                <td>
                    <%--<input type="text" name="approvalTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>--%>
                        <input  name="approvalTime" id="approvalTime"  placeholder="请输入时间"  type="text"  readonly="readonly" />
                </td>
            </tr>
            <tr>
                <td>审批意见:</td>
                <td><input type="text" name="approvalAdvice"/></td>
                <td>备注:</td>
                <td><input type="text" name="remark"/></td>
            </tr>
        </table>
    </form>
</div>
<div class="div_Btn">
    <div class="saveBtn">
        <span  onclick="ajaxforms()" style="margin-left: 32px;">保存</span>
    </div>
    <div class="resetBtn" onclick="javascript:window.location.href='/crmContract/index';">
        <span  style="margin-left: 32px;" >返回</span>
    </div>
</div>
</body>
<script>
    var date = new Date();
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#recieveTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#fistPartySignTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#secondPartySignTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#deliverTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#endTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#validTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#startTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })
    laydate({
        istime: true,
        format: 'YYYY-MM-DD',
        elem: '#approvalTime',
        min:date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    })



    function  ajaxforms() {
        if($('[name="contractName"]').val() == ''){
            layer.msg('请输入合同名称 ！',{icon:6});
        }else if($('[name="type"] option:selected').val() == ''){
            layer.msg('请选择合同类型！',{icon:2});
        }else if($('[name="payWay"] option:selected').val() == ''){
            layer.msg('请选择付款方式！',{icon:2});
        }else if($('[name="customerId"] option:selected').val() == ''){
            layer.msg('请选择所属客户！',{icon:2});
        }else {
        $.ajax({
            url: '/crmContract/addCrmContract',
            type: 'post',
            dataType: 'json',
            data: $('#ajaxforms').serialize(),
            success: function (data) {
                if (data.flag) {
                    layer.open({
                        type: 1
                        , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                        , id: 'layerDemo' + type //防止重复弹出
                        , content: '<div style="padding: 20px 100px;">' + "保存成功!" + '</div>'
                        , btn: '确定'
                        , btnAlign: 'c' //按钮居中
                        , shade: 0 //不显示遮罩
                        , yes: function () {
                            layer.closeAll();
                            window.location.href = '/crmContract/index'
                        }
                    });
                } else {
                    layer.open({
                        type: 1
                        , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                        , id: 'layerDemo' + type //防止重复弹出
                        , content: '<div style="padding: 20px 100px;">' + "保存失败!" + '</div>'
                        , btn: '确定'
                        , btnAlign: 'c' //按钮居中
                        , shade: 0 //不显示遮罩
                        , yes: function () {
                            layer.closeAll();

                        }
                    });
                }
            },
            error: function (data) {
                layer.open({
                    type: 1
                    , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                    , id: 'layerDemo' + type //防止重复弹出
                    , content: '<div style="padding: 20px 100px;">' + "保存失败!" + '</div>'
                    , btn: '确定'
                    , btnAlign: 'c' //按钮居中
                    , shade: 0 //不显示遮罩
                    , yes: function () {
                        layer.closeAll();

                    }
                });
            }
        })
    }

    }
    //付款方式
    $(function () {
        $.ajax({
            url: "/crmContract/selectByPayment",
            type:'get',
            dataType:"JSON",
            success:function(data){
                var str='<option value="">请选择付款方式</option>';
                for (var i=0;i<data.obj.length;i++){
                    str += '<option value="'+data.obj[i].codeNo+'">'+data.obj[i].codeName+'</option>'
                }
                $('[name="payWay"]').html(str);
            }
        })
    })
    //合同类型
    $(function () {
        $.ajax({
            url: "/crmContract/selectByContract",
            type:'get',
            dataType:"JSON",
            success:function(data){
                var str='<option value="">请选择合同类型</option>';
                for (var i=0;i<data.obj.length;i++){
                    str += '<option value="'+data.obj[i].codeNo+'">'+data.obj[i].codeName+'</option>'
                }
                $('[name="type"]').html(str);
            }
        })
    })


    //所属客户
    $(function () {
        $.ajax({
            url: "/crmContract/selectByConditionCust",
            type:'get',
            dataType:"JSON",
            success:function(data){
                var str='<option value="">请选择客户</option>';
                for (var i=0;i<data.obj.length;i++){
                    str += '<option value="'+data.obj[i].customerId+'">'+data.obj[i].customerName+'</option>'
                }
                $('[name="customerId"]').html(str);
            }
        })
    })

</script>

</html>
